﻿using Taype.Trading.BTC.MtGoxAPIClient.JSONObjects;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using Taype.Trading.BTC.MtGoxAPIClient;

namespace MtGoxAPIClient_test
{
    
    
    /// <summary>
    ///This is b test class for MtGoxHistoryItemTest and is intended
    ///to contain all MtGoxHistoryItemTest Unit Tests
    ///</summary>
    [TestClass()]
    public class MtGoxHistoryItemTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in b class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for MtGoxHistoryItem Constructor
        ///</summary>
        [TestMethod()]
        public void MtGoxHistoryItemConstructorTest()
        {
            MtGoxHistoryItem target = new MtGoxHistoryItem();
            Assert.IsNotNull(target);
        }

        /// <summary>
        ///A test for getObjects
        ///</summary>
        [TestMethod()]
        public void getObjectsMtGoxHistoryItemTest()
        {
            string jsonDataStr = "{\"Login\":\"taype-autotrader\",\"Index\":\"110333\",\"Rights\":[\"deposit\",\"get_info\",\"trade\",\"withdraw\"],\"Language\":\"en_US\",\"Created\":\"2012-01-02 20:51:43\",\"Last_Login\":\"2012-01-06 20:00:15\",\"Wallets\":{\"BTC\":{\"Balance\":{\"value\":\"0.86053625\",\"value_int\":\"86053625\",\"display\":\"0.86053625\\u00a0BTC\",\"currency\":\"BTC\"},\"Operations\":1,\"Daily_Withdraw_Limit\":{\"value\":\"400.00000000\",\"value_int\":\"40000000000\",\"display\":\"400.00000000\\u00a0BTC\",\"currency\":\"BTC\"},\"Monthly_Withdraw_Limit\":null,\"Max_Withdraw\":{\"value\":\"400.00000000\",\"value_int\":\"40000000000\",\"display\":\"400.00000000\\u00a0BTC\",\"currency\":\"BTC\"}},\"USD\":{\"Balance\":{\"value\":\"0.00000\",\"value_int\":\"0\",\"display\":\"$0.00000\",\"currency\":\"USD\"},\"Operations\":0,\"Daily_Withdraw_Limit\":{\"value\":\"1000.00000\",\"value_int\":\"100000000\",\"display\":\"$1,000.00000\",\"currency\":\"USD\"},\"Monthly_Withdraw_Limit\":{\"value\":\"10000.00000\",\"value_int\":\"1000000000\",\"display\":\"$10,000.00000\",\"currency\":\"USD\"},\"Max_Withdraw\":{\"value\":\"1000.00000\",\"value_int\":\"100000000\",\"display\":\"$1,000.00000\",\"currency\":\"USD\"}}},\"Trade_Fee\":0.6}";
            MtGoxHistoryItem expected = new MtGoxHistoryItem();
            expected.Created = DateTime.Parse("2012-01-02 20:51:43");
            expected.Index = 110333;
            expected.Language = "en_US";
            expected.Last_Login = DateTime.Parse("2012-01-06 20:00:15");
            expected.Login = "taype-autotrader";
            expected.Rights = (new List<string>(new string[] {"deposit","get_info","trade","withdraw"}));
            expected.Trade_Fee = 0.6;
            // \"USD\":{\"Balance\":{\"value\":\"0.00000\",\"value_int\":\"0\",\"display\":\"$0.00000\",\"currency\":\"USD\"},\"Operations\":0,\"Daily_Withdraw_Limit\":{\"value\":\"1000.00000\",\"value_int\":\"100000000\",\"display\":\"$1,000.00000\",\"currency\":\"USD\"},\"Monthly_Withdraw_Limit\":{\"value\":\"10000.00000\",\"value_int\":\"1000000000\",\"display\":\"$10,000.00000\",\"currency\":\"USD\"},\"Max_Withdraw\":{\"value\":\"1000.00000\",\"value_int\":\"100000000\",\"display\":\"$1,000.00000\",\"currency\":\"USD\"}}},\"Trade_Fee\":0.6}";
            expected.Wallets = new List<MtGoxWallet>();
            expected.Wallets.Add(new MtGoxWallet(
                MtGoxCurrencySymbol.USD, 
                new MtGoxWalletBalance(0.00000, 0, "$0.00000", MtGoxCurrencySymbol.USD), 
                0, 
                new MtGoxWithdrawalLimit(1000.00000, 100000000, "$1,000.00000", MtGoxCurrencySymbol.USD), 
                new MtGoxWithdrawalLimit(10000.00000, 1000000000, "$10,000.00000", MtGoxCurrencySymbol.USD), 
                new MtGoxWithdrawalLimit(1000.00000, 100000000, "$1,000.00000", MtGoxCurrencySymbol.USD)));
            // \"Wallets\":{\"BTC\":{\"Balance\":{\"value\":\"0.86053625\",\"value_int\":\"86053625\",\"display\":\"0.86053625\\u00a0BTC\",\"currency\":\"BTC\"},\"Operations\":1,\"Daily_Withdraw_Limit\":{\"value\":\"400.00000000\",\"value_int\":\"40000000000\",\"display\":\"400.00000000\\u00a0BTC\",\"currency\":\"BTC\"},\"Monthly_Withdraw_Limit\":null,\"Max_Withdraw\":{\"value\":\"400.00000000\",\"value_int\":\"40000000000\",\"display\":\"400.00000000\\u00a0BTC\",\"currency\":\"BTC\"}},
            expected.Wallets.Add(new MtGoxWallet(
                MtGoxCurrencySymbol.BTC, 
                new MtGoxWalletBalance(0.86053625, 86053625, "0.86053625\u00a0BTC", MtGoxCurrencySymbol.BTC), 
                1, 
                new MtGoxWithdrawalLimit(400.00000000, 40000000000, "400.00000000\u00a0BTC", MtGoxCurrencySymbol.BTC), 
                null, 
                new MtGoxWithdrawalLimit(400.00000000, 40000000000, "400.00000000\u00a0BTC", MtGoxCurrencySymbol.BTC)));
            MtGoxHistoryItem actual;
            actual = MtGoxHistoryItem.getObjects(jsonDataStr);
            Assert.AreEqual(expected.Created, actual.Created);
            Assert.AreEqual(expected.Index, actual.Index);
            Assert.AreEqual(expected.Language, actual.Language);
            Assert.AreEqual(expected.Last_Login, actual.Last_Login);
            Assert.AreEqual(expected.Login, actual.Login);
            Assert.AreEqual(expected.Rights.Count, actual.Rights.Count);
            Assert.AreEqual(expected.Trade_Fee, actual.Trade_Fee);
            Assert.AreEqual(expected.Wallets.Count, actual.Wallets.Count);
        }
    }
}
